<template>
  <div id="header">
    <!-- <div class="all">全文检索</div> -->
    <div class="menulist">
      <p @click="to_home">首页</p>
      <p @click="to_cnki" class="to-cnki">CNKI搜索</p>
      <p >{{this.$store.state.user.username}}</p>
      <p @click="user_center" class="logout">退出登录</p>
    </div>

    <div class="menulist menulist-mobile">
      <p @click="to_home"><img src="../../assets/image/home.png" alt="" width="30px"></p>
      <p @click="user_center"><img src="../../assets/image/user.png" alt="" width="30px"></p>
    </div>
  </div>
</template>

<script>
export default {
  name: '',
  methods:{
    to_cnki: function () {  
      window.open('http://www.cnki.net/')
    },
    to_home: function () { 
      this.$router.push({
        path:'/'
      })
    },
    user_center: function () { 
      this.$store.state.user = undefined
    }
  },
}
</script>

<style>
#header {
  color: white;
  overflow: hidden;
  font-family:"Microsoft YaHei","微软雅黑",Arial;
  font-size: 14px;
  position: relative;
  z-index: 999;
  background: #7b99da;
  height: 38px;
  /* width: 100%; */
  position: fixed;
}
.all {
  float: left;
  line-height: 35px;
  padding-left: 30px;
}
.menulist {
  position: fixed;
  right: 5px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.menulist p {
  line-height: 35px;
  padding-right: 20px;
  padding-left: 20px;
  cursor: pointer;
  text-align: center;
  position: relative;
  min-width: 56px;
}
.menulist p::before {
  content: '';
  position: absolute;
  left: 100%;
  top: 0;
  border-bottom: 1px solid white;
  width: 0;
  height: 100%;
  transition: all 0.3s;
}
.menulist p:hover::before {
  width: 100%;
  left: 0;
}
.menulist p:hover ~ p::before {
  left: 0;
}
.menulist .logout {
  position: absolute;
  top: 35px;
  right: 0;
  height: 0;
  overflow: hidden;
  transition: all 0.5s;
}
.menulist .logout:hover {
  background: rgba(255 ,255 , 255, 0.2);
  
}
.menulist .logout::before {
  content: '';
  visibility: hidden;
}
.menulist p:nth-child(3):hover + p,.menulist .logout:hover{
  height: 100%;
}
.menulist-mobile {
  display: none;
}
/* .logout::after {
  content: '退出登录' ;
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  transition: all 0.5s;
  height: 0;
  overflow: hidden;
}
.logout:hover::after {
  height: 100%;
} */

/*媒体查询适配移动端*/
@media screen and (max-width:700px){
  .to-cnki {
    display: none;
  }
  .menulist {
    display: none;
  }
  .menulist-mobile {
    display: inline-block;
    z-index: 999;
    top: 0;
  }
  .menulist-mobile p {
    display: inline-block;
    padding:5px 10px;
    height: 5.2vh;
    position: relative;
    z-index: 999;
  }

}
</style>
